<template>
  <div>
    <template v-if="componentType == 'configTable'">
      <el-row v-for="(item, index) in data" style="margin-bottom: 10px" :key="index">
        <el-col :md="4" :xs="8">
          <el-input v-model="item.key" placeholder="请输入key" />
        </el-col>
        <el-col :span="1" style="text-align: center">-</el-col>
        <el-col :md="4" :xs="8">
          <el-input v-model="item.value" placeholder="请输入解释" />
        </el-col>
        <el-col :span="1" :xs="0" style="text-align: center">-</el-col>
        <el-col :md="4" :xs="8">
          <el-select v-model="item.type" placeholder="字段类型">
            <el-option label="字符串" value="string"></el-option>
            <el-option label="整数" value="int"></el-option>
            <el-option label="小数" value="float"></el-option>
          </el-select>
        </el-col>
        <el-col :span="1" style="text-align: center">-</el-col>
        <el-col :md="4" :xs="8">
          <el-select v-model="item.isEdit" placeholder="是否可编辑">
            <el-option label="可编辑" value="1"></el-option>
            <el-option label="不可编辑" value="0"></el-option>
            <el-option label="可新增不可编辑" value="2" v-if="dbDriver == 'ck' "></el-option>
          </el-select>
        </el-col>
        <el-col :md="4" :xs="6" style="margin-left: 10px"
          ><el-button
            @click="delJsonInput(index)"
            type="danger"
            icon="el-icon-minus"
            size="mini"
            circle
          ></el-button>
          <el-button
            v-if="index == data.length - 1"
            @click="addJsonInput"
            type="primary"
            icon="el-icon-plus"
            size="mini"

            circle
          ></el-button>
        </el-col>
      </el-row>
    </template>
    <template v-if="componentType == 'statCondition'">
      <el-row v-for="(item, index) in data" style="margin-bottom: 10px" :key="index">
        <el-col :md="4" :xs="10">
          <el-input v-model="item.value" placeholder="条件值" />
        </el-col>
        <el-col :span="1" style="text-align: center">-</el-col>
        <el-col :md="4" :xs="10">
          <el-input v-model="item.key" placeholder="替换字段" />
        </el-col>
        <el-col :span="1" :xs="0" style="text-align: center">-</el-col>
        <el-col :md="8" :xs="10">
          <el-input v-model="item.replaceValue" placeholder="替换值" />
        </el-col>
        <el-col :span="1" style="text-align: center">-</el-col>
        <el-col :md="4" :xs="10" style="margin-left: 10px"
          ><el-button
            @click="delJsonInput(index)"
            type="danger"
            icon="el-icon-minus"
            size="mini"

            circle
          ></el-button>
          <el-button
            v-if="index == data.length - 1"
            @click="addJsonInput"
            type="primary"
            icon="el-icon-plus"
            size="mini"

            circle
          ></el-button>
        </el-col>
      </el-row>
    </template>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    data: {
      type: Array,
      required: true,
    },
    componentType: {
      type: String,
      required: true,
    },
    dbDriver: {
        type:String,
    },
  },
  methods: {
    addJsonInput() {
      this.$emit("addJsonInput");
    },
    delJsonInput(index) {
      this.$emit("delJsonInput", { index });
    },
  },
  computed: {},
};
</script>

<style></style>
